package org.example.blog.config;


import org.example.blog.constants.Constants;
import org.example.blog.model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@ResponseBody
@ControllerAdvice
public class ErrorAdvice {
    @ExceptionHandler
    public Result errorHandler(Exception e) {
        Result result = new Result<>();
        result.setErrMsg("内部发生错误, 请联系管理员.");
        result.setCode(Constants.RESULT_FAIL);
        return result;
    }
}
